package com.example.hehecat.yuejian1.mvp.model;

import com.example.hehecat.yuejian1.http.RetrofitHttp;
import com.example.hehecat.yuejian1.mvp.contract.ClubInfoContract;
import com.example.hehecat.yuejian1.mvp.model.bean.ClubBean;
import com.example.hehecat.yuejian1.mvp.model.bean.ClubLessonBean;
import com.example.hehecat.yuejian1.mvp.model.bean.SuccessBean;

import java.util.List;

import okhttp3.OkHttpClient;
import retrofit2.Callback;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class ClubInfoModel implements ClubInfoContract.Model {
    @Override
    public void getClub(int club_id, Subscriber<ClubBean> subscriber) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).getclubInfo(club_id)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    @Override
    public void getLesson(int club_id, Subscriber<List<ClubLessonBean>> subscriber) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).getClublesson(club_id)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    @Override
    public void collectClub(int club_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).collectClub(user_id, club_id)
                .enqueue(callback);
    }

    @Override
    public void isClubCollect(int club_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).isClubCollect(user_id, club_id)
                .enqueue(callback);
    }
}
